﻿/// <reference path="../../../Scripts/Jquery/jquery-1.7.1-vsdoc.js" />
/// <reference path="../../../Scripts/Jquery/jquery-ui-1.8.18.custom.min.js" />
/// <reference path="../../../Scripts/Jquery/jquery.validate-vsdoc.js" />

if (typeof (Solution) == 'undefined') Solution = {};
if (typeof (Solution.Admin) == 'undefined') Solution.Admin = {};
Solution.Admin.Core = {
    Init: function () {
        this.BindEventNotif();

    },
    BindEventNotif: function () {
        $('.notif.bloc a').live('click', function () {
            var prr = $(this).parent();
            $(prr).hide('fast', function () {
                $(prr).addClass('HideNotif');
            });

        });
        var Normal = $('.nvbar #Normal');
        var ShowBin = $('.nvbar #ShowBin');
        $(Normal).live('click', function () {
            $(this).removeAttr('Class');
            $(ShowBin).removeAttr('Class');
            $(this).addClass('blue');
            $(ShowBin).addClass('white');
        });
        $(ShowBin).live('click', function () {
            $(this).removeAttr('Class');
            $(Normal).removeAttr('Class');
            $(this).addClass('blue');
            $(Normal).addClass('white');
        });
    },
    InitNotif: function () {
        var str = '';
        str += '  <div class="notif success bloc HideNotif">                                     ';
        str += '      <strong>Success :</strong> <span></span><a href="#" class="close">x</a>    ';
        str += '  </div>                                                                         ';
        str += '  <div class="notif warning bloc HideNotif">                                     ';
        str += '      <strong>Warning !</strong> <span></span><a href="#" class="close">x</a>    ';
        str += '  </div>                                                                         ';
        str += '  <div class="notif error bloc HideNotif">                                       ';
        str += '      <strong>Error :</strong> <span></span><a href="#" class="close">x</a>      ';
        str += '  </div>                                                                         ';
        $(str).insertAfter('#InitNotif');
    },
    ShowNotif: function (ctr, time, strmMess) {
        var Obj = '.notif.bloc';
        $(Obj).addClass('HideNotif');
        $(Obj).removeAttr('style');
        var _inMess = '';
        switch (ctr) {
            case 's': Obj += '.success'; _inMess += 'Thao tác thành công!'; break;
            case 'w': Obj += '.warning'; _inMess += 'Cảnh báo!'; break;
            case 'e': Obj += '.error'; _inMess += 'Đã có lỗi xảy ra, kiểm tra lại thông tin!'; break;
            default: break;

        }
        $(Obj).removeClass('HideNotif');
        var ObjSpan = Obj + ' span';
        if (typeof strmMess != 'undefined')
            $(ObjSpan).html(strmMess);
        else
            $(ObjSpan).html(_inMess);
        if (typeof time != 'undefined') {
            if (time > 0)
                setTimeout(function () {
                    $(Obj).hide('fast', function () {
                        $(Obj).addClass('HideNotif');
                    });
                }, time);
            else
                if (time == 0)// default
                    setTimeout(function () {
                        $(Obj).hide('fast', function () {
                            $(Obj).addClass('HideNotif');
                        });
                    }, 3500);
        }

    }
}